public class Threadtest4 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{

            for (int i = 0; i < 5; i++) {
                try {
                    Thread.sleep(1000);
                    System.out.println(Thread.currentThread().getName()+"在干活...");
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
            System.out.println(Thread.currentThread().getName()+"干完活了");
        },"李四");

        Thread mainthread = new Thread(()->{
            try {
                System.out.println("main 开始等待...");
                t.join();
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println("main终于结束等待...");
        });
        t.start();
/*
        mainthread.start();*/
        try {
            Thread.sleep(10000);
            mainthread.start();
        } catch (InterruptedException e) {

            throw new RuntimeException(e);
        }
    }
}
